from typing import *


class Solution:
    def sumOfPower(self, nums: List[int]) -> int:
        nums.sort()
        ans = x = p = 0 
        for num in nums:
            x <<= 1
            x += p
            ans += num * num * x + num * num * num
            p = num
            
        return ans % 1000000007
